﻿using System;
using System.Collections.Generic;
using System.Text;
using ECC_EXT_Entity;
using NHibernate;
using NHibernate.Criterion;

namespace ECC_EXT_DAO.Dao
{
    public class MailLogDao : DaoBase
    {
        public void SaveOrUpdate(MailLogEntity _mailLogEntity)
        {
            using (ISession session = this.SessionFactory.OpenSession())
            {
                session.BeginTransaction();
                session.SaveOrUpdate(_mailLogEntity);
                session.Transaction.Commit();
            }
        }


        public IList<MailLogEntity> Search(MailLogEntity _mailLogEntity)
        {
            using (ISession session = this.SessionFactory.OpenSession())
            {
                ICriteria criteria =
                    session.CreateCriteria<MailLogEntity>();
                criteria.Add(Restrictions.Eq("MailNo", _mailLogEntity.MailNo));
                //criteria.Add(Restrictions.Eq("CategoryFullName", _mailLogEntity.CategoryFullName));
                return
                criteria.List<MailLogEntity>();
            }
        }
    }
}
